//
//  TravelsTopicDetailsTableViewCell.m
//  艾听歌
//
//  Created by dllo on 16/5/28.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TravelsTopicDetailsTableViewCell.h"

#import "height_FZFF.h"



#define CellW self.contentView.frame.size.width
#define CellH self.contentView.frame.size.height

#define TopSpace 10
#define LeftSpace 10


@implementation TravelsTopicDetailsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self createSubviews];
        
    }
    
    return  self;
}


- (void)createSubviews{
    
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.backgroundColor= [UIColor whiteColor];
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.font = [UIFont systemFontOfSize:22];
    
    self.image_url = [[UIImageView alloc]init];
    self.image_url.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.image_url];
    
    
    self.descriptionLabel = [[UILabel alloc]init];
    self.descriptionLabel.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.descriptionLabel];
    self.descriptionLabel.font = [UIFont systemFontOfSize:15];

    
}


- (void)layoutSubviews{
    
//    NSLog(@"%@", self.cellRowModel);
    //用自适应高度给坐标
    
    CGFloat titleLabelHeight = [height_FZFF getLabelHeightWithString:self.cellRowModel.title widthNowLabel:CellW - LeftSpace * 2 fontSize:25 options:NSStringDrawingUsesLineFragmentOrigin];
    self.titleLabel.frame = CGRectMake(LeftSpace, TopSpace, CellW - LeftSpace * 2, titleLabelHeight);
    self.titleLabel.text = self.cellRowModel.title;
    self.titleLabel.numberOfLines = 0;
    
    CGFloat imageHeight = [height_FZFF getHeightImageWithHeight:self.cellRowModel.image_height withWidth:self.cellRowModel.image_width widthNowImage:CellW - LeftSpace *2];

    self.image_url.frame = CGRectMake(LeftSpace, TopSpace  + titleLabelHeight, CellW - LeftSpace * 2, imageHeight);
    [self.image_url sd_setImageWithURL:[NSURL URLWithString:self.cellRowModel.image_url] placeholderImage:[UIImage imageNamed:@"holderr"]];
    
    
    CGFloat descriptionLabelHeight = [height_FZFF getLabelHeightWithString:self.cellRowModel.descriptions widthNowLabel:CellW - LeftSpace * 2 fontSize:15 options:NSStringDrawingUsesLineFragmentOrigin];
    self.descriptionLabel.frame = CGRectMake(LeftSpace, TopSpace  + titleLabelHeight + imageHeight, CellW - LeftSpace * 2, descriptionLabelHeight);
    self.descriptionLabel.text = self.cellRowModel.descriptions;
    self.descriptionLabel.numberOfLines = 0;
    
}




@end
